// ***********************************************
// * Script: Lever                               *
// * Author: Kelandon                            *
// ***********************************************

// Lever v1.0.0
// lever.txt (variant of my Search-Step)
// by Kelandon (tomwatts@berkeley.edu)
// A script for levers.

// Memory Cells - 
//  0 - Number of a state in the town script. This is the state that is called 
//	when the item is used.

beginterrainscript; 

variables;

short choice;

body;

beginstate INIT_STATE;
break;

beginstate START_STATE;
break;

beginstate SEARCH_STATE;
	set_state_continue(10);
break;
        
beginstate STEP_INTO_SPOT_STATE;
	set_state_continue(10);
break;

beginstate 10;
	reset_dialog_preset_options(2);
	choice = run_dialog(1);
	if (choice == 2) {
		flip_terrain(my_loc_x(), my_loc_y());
		play_sound(-94);
		if (get_terrain(my_loc_x(), my_loc_y()) == 374)
			end();
		if (get_memory_cell(0) > 0)
			run_town_script(get_memory_cell(0));
	}
break;
